#include "stdafx.h"
#include "Geometry.h"
#include <memory.h>

Box3D::Box3D(void)
{
	memset(this, 0, sizeof(Box3D));
}

Box3D::Box3D(float left, float right, float top, float bottom, float front, float back)
{
	this->left = left;
	this->right = right;
	this->front = front;
	this->back = back;
	this->top = top;
	this->bottom = bottom;
}

Sphere3D::Sphere3D(void)
{
	memset(this, 0, sizeof(Sphere3D));
}

Sphere3D::Sphere3D(float x, float y, float z, float radius)
{
	this->center = Vector3(x, y, z);
	this->radius = radius;
}

Sphere3D::Sphere3D(Vector3 xyz, float radius)
{
	this->center = xyz;
	this->radius = radius;
}

Sphere3D::Sphere3D(Vector4 xyzw)
{
	this->center = xyzw.getXyz();
	this->radius = xyzw.w;
}

Box2D::Box2D(void)
{
	memset(this, 0, sizeof(Box2D));
}

Box2D::Box2D(float left, float right, float top, float bottom)
{
	this->left = left;
	this->right = right;
	this->top = top;
	this->bottom = bottom;
}

Box2D::Box2D(Vector2 location, float width, float height)
{
	this->left = location.x;
	this->top = location.y;
	this->right = location.x + width;
	this->bottom = location.y + height;
}

bool Box2D::Contains(Vector2 value)
{
	return value.x >= left && value.y <= right &&
		value.y >= top && value.y <= bottom;
}

void Box2D::setPosition(Vector2 value)
{
	float width = getWidth();
	float height = getHeight();

	left = value.x;
	top = value.y;
	right = value.x + width;
	bottom = value.y + height;
}